
from django.db import models
from django.db.models import TextField

from apps.system.models import User
from extensions.common.base import *
from extensions.models import *


#评测名称
class Evaluation(Model):
    name = CharField(max_length=255, verbose_name='评测名称', null=True, blank=True)
    # 前端评测路由path
    path = CharField(max_length=255, verbose_name='path', null=True, blank=True)
    # modle
    model = CharField(max_length=255, verbose_name='model', null=True, blank=True)
    # api
    api = CharField(max_length=255, verbose_name='api', null=True, blank=True)

    class Meta:
        verbose_name = '评测名称'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name

# 参评权限
class Evaluation_Authority(Model):
    name = CharField(max_length=50, verbose_name='参评权限名称', null=True, blank=True)

    class Meta:
        verbose_name = '参评权限'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name

#评测列表
class Evaluation_List(Model):
    evaluation= ForeignKey(Evaluation, on_delete=models.CASCADE, verbose_name='评测名称', null=True, blank=True, related_name='Evaluation_List_evaluation')
    # 评测期别
    evaluation_period = CharField(max_length=50, verbose_name='评测期别', null=True, blank=True)
    # 开始时间
    start_time = DateField(verbose_name='开始时间', null=True, blank=True)
    # 结束时间
    end_time = DateField(verbose_name='结束时间', null=True, blank=True)
    # 评测状态
    evaluation_status = CharField(max_length=50, verbose_name='评测状态', null=True, blank=True)

    # 参评权限
    evaluation_authority = ForeignKey(Evaluation_Authority, on_delete=models.CASCADE, verbose_name='参评权限', null=True, blank=True, related_name='Evaluation_List_evaluation_authority')
    class Meta:
        verbose_name = '评测列表'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.evaluation.name


#数智工程支撑中心(业务部门评价)
class DigitalIntelligence_BusinessDepartment(Model):
    #评测项
    evaluation_item = ForeignKey(Evaluation_List, on_delete=models.CASCADE, verbose_name='评测项', null=True, blank=True, related_name='DigitalIntelligence_BusinessDepartment_evaluation_item')
    #报表材料支撑
    report_material_support = FloatField(default=False, verbose_name='报表材料支撑')
    # 报表材料支撑扣分原因
    report_material_support_reason = TextField(verbose_name='报表材料支撑扣分原因', null=True, blank=True)
    #解决方案支撑
    solution_support = FloatField(default=False, verbose_name='解决方案支撑')
    # 解决方案支撑扣分原因
    solution_support_reason = TextField(verbose_name='解决方案支撑扣分原因', null=True, blank=True)
    #现场交付及安全质量监督检查支撑
    site_delivery_support = FloatField(default=False, verbose_name='现场交付及安全质量监督检查支撑')
    # 现场交付及安全质量监督检查支撑扣分原因
    site_delivery_support_reason = TextField(verbose_name='现场交付及安全质量监督检查支撑扣分原因', null=True, blank=True)
    #业务投标支撑
    business_bid_support = FloatField(default=False, verbose_name='业务投标支撑')
    # 业务投标支撑扣分原因
    business_bid_support_reason = TextField(verbose_name='业务投标支撑扣分原因', null=True, blank=True)
    #总分
    total_score = FloatField(default=False, verbose_name='总分')
    #评测人
    reviewer = ForeignKey(User, on_delete=models.CASCADE, verbose_name='评测人', null=True, blank=True, related_name='DigitalIntelligence_BusinessDepartment_reviewer')
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.evaluation_item} - {self.reviewer}"


#数智工程支撑中心(地市分公司评价)
class DigitalIntelligence_Branch_office(Model):
    #评测项
    evaluation_item = ForeignKey(Evaluation_List, on_delete=models.CASCADE, verbose_name='评测项', null=True, blank=True, related_name='DigitalIntelligence_Branch_office_evaluation_item')
    #投标过程支撑
    bid_process_support = FloatField(default=False, verbose_name='投标过程支撑')
    # 投标过程支撑扣分原因
    bid_process_support_reason = TextField(verbose_name='投标过程支撑扣分原因', null=True, blank=True)
    #投标资源支撑
    bid_resource_support = FloatField(default=False, verbose_name='投标资源支撑')
    # 投标资源支撑扣分原因
    bid_resource_support_reason = TextField(verbose_name='投标资源支撑扣分原因', null=True, blank=True)
    #总分
    total_score = FloatField(default=False, verbose_name='总分')
    #评测人
    reviewer = ForeignKey(User, on_delete=models.CASCADE, verbose_name='评测人', null=True, blank=True, related_name='DigitalIntelligence_Branch_office_reviewer')
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.evaluation_item} - {self.reviewer}"


#智慧生活支撑中心(业务部门评价)
class SmartLifeSupportCenter_BusinessDepartment(Model):
    #评测项
    evaluation_item = ForeignKey(Evaluation_List, on_delete=models.CASCADE, verbose_name='评测项', null=True, blank=True, related_name='SmartLifeSupportCenter_BusinessDepartment_evaluation_item')
    #报表统计分析
    report_statistics_analysis = FloatField(default=False, verbose_name='报表统计分析')
    #报表统计分析扣分原因
    report_statistics_analysis_reason = CharField(max_length=255, verbose_name='报表统计分析扣分原因', null=True, blank=True)
    #质量过程管控
    quality_process_control = FloatField(default=False, verbose_name='质量过程管控')
    #质量过程管控扣分原因
    quality_process_control_reason = CharField(max_length=255, verbose_name='质量过程管控扣分原因', null=True, blank=True)
    #业务部门月度重点工作支撑
    business_monthly_support = FloatField(default=False, verbose_name='业务部门月度重点工作支撑')
    #业务部门月度重点工作支撑扣分原因
    business_monthly_support_reason = CharField(max_length=255, verbose_name='业务部门月度重点工作支撑扣分原因', null=True, blank=True)
    #总部工单执行
    headquarters_work_order_execution = FloatField(default=False, verbose_name='总部工单执行')
    #总部工单执行扣分原因
    headquarters_work_order_execution_reason = CharField(max_length=255, verbose_name='总部工单执行扣分原因', null=True, blank=True)
    #总分
    total_score = FloatField(default=False, verbose_name='总分')
    #评测人
    reviewer = ForeignKey(User, on_delete=models.CASCADE, verbose_name='评测人', null=True, blank=True, related_name='SmartLifeSupportCenter_BusinessDepartment_reviewer')
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.evaluation_item} - {self.reviewer}"


#智慧生活支撑中心(地市分公司评价)
class SmartLifeSupportCenter_BranchOffice(Model):
    #评测项
    evaluation_item = ForeignKey(Evaluation_List, on_delete=models.CASCADE, verbose_name='评测项', null=True, blank=True, related_name='SmartLifeSupportCenter_BranchOffice_evaluation_item')
    #质量通报
    quality_bulletin = FloatField(default=False, verbose_name='质量通报')
    #质量通报扣分原因
    quality_bulletin_deduction_reason = TextField(null=True, blank=True,default=False, verbose_name='质量通报扣分原因')
    #地市工作支撑
    city_work_support = FloatField(default=False, verbose_name='地市工作支撑')
    #地市工作支撑扣分原因
    city_work_support_deduction_reason = TextField(null=True, blank=True,default=False, verbose_name='地市工作支撑扣分原因')
    #地市短板指标支撑
    city_shortboard_index_support = FloatField(default=False, verbose_name='地市短板指标支撑')
    #地市短板指标支撑扣分原因
    city_shortboard_index_support_deduction_reason = TextField(null=True, blank=True,default=False, verbose_name='地市短板指标支撑扣分原因')
    #技术支撑
    technical_support = FloatField(default=False, verbose_name='技术支撑')
    #技术支撑扣分原因
    technical_support_deduction_reason = TextField(null=True, blank=True,default=False, verbose_name='技术支撑扣分原因')
    #总分
    total_score = FloatField(default=False, verbose_name='总分')
    #评测人
    reviewer = ForeignKey(User, on_delete=models.CASCADE, verbose_name='评测人', null=True, blank=True, related_name='SmartLifeSupportCenter_BranchOffice_reviewer')
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"{self.evaluation_item} - {self.reviewer}"

#被评测人
class Be_Evaluated_Person(Model):
    #被评测人姓名
    name = CharField(max_length=255, verbose_name='被评测人姓名', null=True, blank=True)
    #被评测人所属部门
    department = CharField(max_length=255, verbose_name='被评测人所属部门', null=True, blank=True)
    #被评测人所属类别（三级经理还是一般员工）
    category = CharField(max_length=255, verbose_name='被评测人所属类别', null=True, blank=True)
    #被评测人真实部门
    real_department = CharField(max_length=255, verbose_name='被评测人真实部门', null=True, blank=True)

    def __str__(self):
        return f"{self.name} "


